package pecan.ui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.EventQueue;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;

public class Main {

	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main window = new Main();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Main() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 600, 500);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new BorderLayout(0, 0));
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setResizeWeight(0.7);
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		
		JScrollPane scrollPane = new JScrollPane();
		splitPane.setRightComponent(scrollPane);
		
		JTextArea msgTextArea = new JTextArea();
		msgTextArea.setLineWrap(true);
		scrollPane.setViewportView(msgTextArea);
		
		JPanel panel = new JPanel();
		splitPane.setLeftComponent(panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		JPanel buttonListPanel = new JPanel();
		panel.add(buttonListPanel, BorderLayout.EAST);
		buttonListPanel.setLayout(new BoxLayout(buttonListPanel, BoxLayout.X_AXIS));
		
		JButton addActionButton = new JButton("添加");
		addActionButton.setAlignmentY(Component.TOP_ALIGNMENT);
		buttonListPanel.add(addActionButton);
		
		JScrollPane actionListPanel = new JScrollPane();
		panel.add(actionListPanel, BorderLayout.CENTER);
		
		JList actionList = new JList();
		actionListPanel.setViewportView(actionList);
		frame.getContentPane().add(splitPane, BorderLayout.CENTER);
	}
}
